<template>
  <div>
    <!-- <title-name title="考察信息填写链接"></title-name> -->
    <a-form-model
      ref="ruleForm"
      :model="serviceList"
      :label-col="{span: 6 }"
      :wrapper-col="{span: 18 }"
      :rules="rules"
    >
      <!-- <a-row>
        <a-col  :md="10" :sm="10">
          <a-form-model-item
                  :wrapperCol="{ lg: { span: 24 }, sm: { span: 24 } }">
            <BaseInput  :disabled="disabled"  v-model="form.subcontractorName"  placeholder="请输入"   />
          </a-form-model-item>
        </a-col>
        <a-col>
          <a-button :disabled="disabled"  style="margin:0 20px" type="primary">复制链接</a-button>
          <a-button :disabled="disabled"  type="primary">生成二维码</a-button>
        </a-col>
      </a-row> -->
      <title-name title="分包商基础信息" />
      <a-row>
        <a-col
          :md="8"
          :sm="8"
        >
          <a-form-model-item
            label="分包商名称"
          >
            <BaseInput
              v-model="serviceList.subcontractorName"
              disabled
              placeholder="请输入"
            />
          </a-form-model-item>
        </a-col>
        <a-col
          :md="8"
          :sm="8"
        >
          <a-form-model-item
            label="主管部门"
            prop="department"
          >
            <BaseInput
              v-model="serviceList.department"
              :disabled="disabled"
              :max-length="30"
              placeholder="请输入"
            />
          </a-form-model-item>
        </a-col>
        <a-col
          :md="8"
          :sm="8"
        >
          <a-form-model-item
            label="联系人"
            prop="contacts"
          >
            <BaseInput
              v-model="serviceList.contacts"
              :disabled="disabled"
              :max-length="30"
              placeholder="请输入"
            />
          </a-form-model-item>
        </a-col>
        <a-col
          :md="8"
          :sm="8"
        >
          <a-form-model-item
            label="电话"
            prop="phone"
          >
            <BaseInput
              v-model="serviceList.phone"
              :disabled="disabled"
              :max-length="30"
              placeholder="请输入"
            />
          </a-form-model-item>
        </a-col>
        <a-col
          :md="8"
          :sm="8"
        >
          <a-form-model-item
            label="公司传真"
            prop="fax"
          >
            <BaseInput
              v-model="serviceList.fax"
              :disabled="disabled"
              :max-length="30"
              placeholder="请输入"
            />
          </a-form-model-item>
        </a-col>
        <a-col
          :md="8"
          :sm="8"
        >
          <a-form-model-item
            label="邮政编码"
            prop="postalCode"
          >
            <BaseInput
              v-model="serviceList.postalCode"
              :disabled="disabled"
              :max-length="30"
              placeholder="请输入"
            />
          </a-form-model-item>
        </a-col>
        <a-col
          :md="12"
          :sm="12"
        >
          <a-form-model-item
            label="单位地址"
            prop="address"
          >
            <BaseTextarea
              v-model="serviceList.address"
              :disabled="disabled"
              :max-length="300"
              placeholder="请输入"
            />
          </a-form-model-item>
        </a-col>
      </a-row>
      <title-name title="评定依据" />
      <a-row>
        <a-col
          :md="8"
          :sm="8"
        >
          <a-form-model-item
            label="纳税人资格"
            class="radio-box"
            prop="taxpayer"
          >
            <!-- <a-radio-group v-model="serviceList.taxpayer" name="radioGroup" :default-value="1">
              <a-radio :value="1">
                一般纳税人
              </a-radio>
             <a-radio :value="2">
               小规模纳税人
             </a-radio>
            </a-radio-group> -->
            <a-radio-group
              v-model="serviceList.taxpayer"
              :disabled="disabled"
              :options="taxpayerList"
            />
          </a-form-model-item>
        </a-col>
        <a-col
          :md="8"
          :sm="8"
        >
          <a-form-model-item
            label="公司成立时间"
            prop="companyCreateTime"
          >
            <a-date-picker
              v-model="serviceList.companyCreateTime"
              :disabled="disabled"
              placeholder="请选择成立时间"
              @change="onChange"
            />
          </a-form-model-item>
        </a-col>
        <a-col
          :md="8"
          :sm="8"
        >
          <a-form-model-item
            label="注册资金(万)"
            prop="registerCapital"
          >
            <BaseInputNumber
              v-model="serviceList.registerCapital"
              :min="0"
              :disabled="disabled"
              :max-length="30"
              placeholder="请输入"
            />
          </a-form-model-item>
        </a-col>
      </a-row>
      <a-row>
        <a-col
          :md="8"
          :sm="8"
        >
          <a-form-model-item
            label="法定代表人姓名"
            prop="legalRepresentative"
          >
            <BaseInput
              v-model="serviceList.legalRepresentative"
              :disabled="disabled"
              :max-length="30"
              placeholder="请输入"
            />
          </a-form-model-item>
        </a-col>
        <a-col
          :md="8"
          :sm="8"
        >
          <a-form-model-item
            label="法定代表人电话"
            prop="resphone"
          >
            <BaseInput
              v-model="serviceList.resphone"
              :disabled="disabled"
              :max-length="30"
              placeholder="请输入"
            />
          </a-form-model-item>
        </a-col>
        <a-col
          :md="8"
          :sm="8"
        >
          <a-form-model-item
            label="统一社会信用代码"
            prop="license"
          >
            <BaseInput
              v-model="serviceList.license"
              :disabled="disabled"
              :max-length="30"
              placeholder="请输入"
            />
          </a-form-model-item>
        </a-col>
      </a-row>
      <a-row>
        <a-col
          :md="8"
          :sm="8"
        >
          <a-form-model-item
            label="资质证书编号"
            prop="qualificationCertificate"
          >
            <BaseInput
              v-model="serviceList.qualificationCertificate"
              :disabled="disabled"
              :max-length="30"
              placeholder="请输入"
            />
          </a-form-model-item>
        </a-col>
        <a-col
          :md="8"
          :sm="8"
        >
          <a-form-model-item
            label="资质类别等级"
            prop="qualityLevel"
          >
            <BaseInput
              v-model="serviceList.qualityLevel"
              :disabled="disabled"
              :max-length="30"
              placeholder="请输入"
            />
          </a-form-model-item>
        </a-col>
        <a-col
          :md="8"
          :sm="8"
        >
          <a-form-model-item
            label="考察引进拟参与内容"
            prop="investigateIntroduction"
          >
            <BaseInput
              v-model="serviceList.investigateIntroduction"
              :disabled="disabled"
              :max-length="30"
              placeholder="请输入"
            />
          </a-form-model-item>
        </a-col>
      </a-row>
      <a-row>
        <a-col
          :md="8"
          :sm="8"
        >
          <a-form-model-item
            label="实际负责人姓名"
            prop="actualName"
          >
            <BaseInput
              v-model="serviceList.actualName"
              :disabled="disabled"
              :max-length="30"
              placeholder="请输入"
            />
          </a-form-model-item>
        </a-col>
        <a-col
          :md="8"
          :sm="8"
        >
          <a-form-model-item
            label="实际负责人电话"
            prop="actualPhone"
          >
            <BaseInput
              v-model="serviceList.actualPhone"
              :disabled="disabled"
              :max-length="30"
              placeholder="请输入"
            />
          </a-form-model-item>
        </a-col>
        <a-col
          :md="8"
          :sm="8"
        >
          <a-form-model-item
            label="安全生产许可证编号"
            prop="securityCode"
          >
            <BaseInput
              v-model="serviceList.securityCode"
              :disabled="disabled"
              :max-length="30"
              placeholder="请输入"
            />
          </a-form-model-item>
        </a-col>
      </a-row>
      <a-row>
        <a-col
          :md="12"
          :sm="12"
        >
          <a-form-model-item
            label="资质等级及承揽工程范围"
            prop="qualificationLevel"
          >
            <BaseTextarea
              v-model="serviceList.qualificationLevel"
              :disabled="disabled"
              :max-length="300"
              placeholder="请输入"
            />
          </a-form-model-item>
        </a-col>
        <a-col
          :md="12"
          :sm="12"
        >
          <a-form-model-item
            label="考察及相关方了解情况"
            prop="relatedParties"
          >
            <BaseTextarea
              v-model="serviceList.relatedParties"
              :disabled="disabled"
              :max-length="300"
              placeholder="请输入"
            />
          </a-form-model-item>
        </a-col>
      </a-row>
      <a-row>
        <a-col
          :md="12"
          :sm="12"
        >
          <a-form-model-item
            label="合同履约能力"
            prop="contractPerformance"
          >
            <BaseTextarea
              v-model="serviceList.contractPerformance"
              :disabled="disabled"
              :max-length="300"
              placeholder="请输入"
            />
          </a-form-model-item>
        </a-col>
      </a-row>
  
      <title-name title="考察小组意见" />
      <a-row>
        <a-col
          :md="8"
          :sm="8"
        >
          <a-form-model-item
            label="考察小组意见"
            prop="groupOption"
          >
            <BaseInput
              v-model="serviceList.groupOption"
              :disabled="disabled"
              :max-length="30"
              placeholder="请输入"
            />
          </a-form-model-item>
        </a-col>
      </a-row>
    </a-form-model>
    <a-button
      v-if="type != 'share'"
      style="float:right;"
      type="primary"
      @click="goNext"
    >
      下一步
    </a-button>
  </div>
</template>

<script>
  import { getService, addInformatinService, editInformatinService} from '@/api/subcontractors/subcontractors'
  import {getStatusCodeData  } from '@/api/subcontractors/labor'
  import { isFax, isPostCode ,isPhone, isSocialcredit, createValidator} from '@/utils/regExpression'
  export default {
    name: 'Service',
    data(){
      return{
        remark:'',
        type:'',
        taxpayerList:[],
        form:{
          subcontractorBase:{},
          investigate:{},
          constructionProject:{}
        },
        id:'',
      // 校验规则
      rules: {
        // department: [{ required: true, message: '请填写主管部门', trigger: 'blur' }],
        // address: [{ required: true, message: '请填写单位地址', trigger: 'blur' }],
        // fax: [{ required: true, message: '请填写传真', trigger: 'blur' }],
        // phone: [{ required: true, message: '请填写法定代表人电话	', trigger: 'blur' }],
        // contacts: [{ required: true, message: '请填写联系人	', trigger: 'blur' }],
        // postalCode: [{ required: true, message: '请填写邮政编码	', trigger: 'blur' }],
        // taxpayer: [{ required: true, message: '请填写纳税人  ', trigger: 'change' }],
        // legalRepresentative: [{ required: true, message: '请填写法定代表人	', trigger: 'blur' }],
        // registerCapital: [{ required: true, message: '请填写注册资金	', trigger: 'blur' }],
        // companyCreateTime	: [{ required: true, message: '请选择公司成立时间	', trigger: 'change' }],
        // qualificationCertificate: [{ required: true, message: '请填写资质证书	', trigger: 'blur' }],
        // license: [{ required: true, message: '请填写社会统一信用代码', trigger: 'blur' }],
        // resphone: [{ required: true, message: '请填写法定代表人电话', trigger: 'blur' }],
        // securityLicense: [{ required: true, message: '请填写安全生产许可证号 ', trigger: 'blur' }],
        // securityEndTime: [{ required: true, message: '请填写安全生产许可证有效期截至时间	', trigger: 'blur' }],
        // qualificationLevel: [{ required: true, message: '请填写资质等级及承揽工程范围考察及相关方了解情况	', trigger: 'blur' }],
        // representativeProjectName: [{ required: true, message: '请填写考察代表工程名称	', trigger: 'blur' }],
        // representativeProjectStructure: [{ required: true, message: '请填写考察代表工程规模结构类型	', trigger: 'blur' }],
        // representativeProjectGeneralContractor: [{ required: true, message: '请填写考察代表工程总承包单位	', trigger: 'blur' }],
        // latestThreeYearsProjectName: [{ required: true, message: '请填写近三年施工项目名称	', trigger: 'blur' }],
        // latestThreeYearsProjectStructure: [{ required: true, message: '请填写近三年施工项目工程规模结构类型	', trigger: 'blur' }],
        // latestThreeYearsProjectGeneralContractor: [{ required: true, message: '请填写近三年施工项目工程总承包单位	', trigger: 'blur' }],
        // technicalQuality: [{ required: true, message: '请填写技术质量管理情况	', trigger: 'blur' }],
        // technicalQualityInspector: [{ required: true, message: '请填写技术质量管理考察人	', trigger: 'blur' }],
        // security: [{ required: true, message: '请填写安全管理情况	', trigger: 'blur' }],
        // securityInspector: [{ required: true, message: '请填写安全管理情况考察人', trigger: 'blur' }],
        // contractPerformance: [{ required: true, message: '请填写合同履约能力', trigger: 'blur' }],
        // contractPerformanceInspector: [{ required: true, message: '请填写合同履约能力考察人	', trigger: 'blur' }],
        // comprehensiveLevel: [{ required: true, message: '请填写综合管理水平	', trigger: 'blur' }],
        // relatedParties: [{ required: true, message: '请填写考察及相关方了解情况', trigger: 'blur' }],
        // qualityLevel: [{ required: true, message: '请填写资质类别等级', trigger: 'blur' }],
        // investigateIntroduction: [{ required: true, message: '请填写考察引进拟参与内容', trigger: 'blur' }],
        // actualName: [{ required: true, message: '请填写实际负责人姓名', trigger: 'blur' }],
        // actualPhone: [{ required: true, message: '请填写实际负责人电话', trigger: 'blur' }],
        // securityCode: [{ required: true, message: '请填写安全生产许可证编号', trigger: 'blur' }],
        // groupOption: [{ required: true, message: '请填写考察小组意见', trigger: 'blur' }],
          phone: [{ validator: createValidator(isPhone, '手机号格式不正确', false,this.validChanged), trigger: 'blur'}],
          actualPhone: [{ validator: createValidator(isPhone, '手机号格式不正确', false,this.validChanged), trigger: 'blur'}],
          resphone: [{ validator: createValidator(isPhone, '手机号格式不正确', false,this.validChanged), trigger: 'blur'}],
          license: [{ validator: createValidator(isSocialcredit, '社会统一信用代码格式不正确', false, this.validChanged), trigger: 'blur'}],
          fax: [{ validator: createValidator(isFax, '公司传真格式不正确', false, this.validChanged), trigger: 'blur'}],
          postalCode: [{ validator: createValidator(isPostCode, '邮政编码格式不正确', false, this.validChanged), trigger: 'blur'}],
     },
      }
    },
    props:["serviceList",'disabled'],
    created() {
      this.id = this.$route.query.id
      this.type = this.$route.query.type
      if(this.$route.fullPath=='/project/subcontractors/investigate/view'){
        this.type='view'
      }
      // if(this.type!='view' || type!='approve'){
        this.getStatusCodeData()
      // }
      this.serviceList.subType = "服务类分包商考察"
    },
    mounted(){
      // this.getInformatinService()
    },
    methods:{
      validChanged(data) {
        console.log(data)
        this.$emit('validChanged', data)
      },
      onChange(value,dateString){
        this.form.companyCreateTime = dateString
      },
      save(){
        this.form.surveyId = this.id
        editInformatinService(this.serviceList).then(res=>{

        })
      },
      getStatusCodeData(){
        getStatusCodeData({type:'9'}).then(res=>{
          this.taxpayerList = res.data
          this.taxpayerList.forEach(item=>{
            item.label=item.name
            item.value=item.id
          })
        })
      },
      edit(){
        this.form.surveyId = this.id
        editInformatinService(this.form).then(res=>{

        })
      },
      goNext(){
        console.log(this.serviceList)
        // this.$refs.ruleForm.validate(valid=>{
        //   if(valid){
            this.$emit("submitNext",this.serviceList)
        //   }
        // })
      },
      // getService(){
      //   getService({id:this.id}).then((res)=>{
      //     // this.form = res
      //     console.log(res.phone+"服务")
      //   })
      // }
    }
  }
</script>

<style lang="less" scoped>
.radio-box {
    .ant-radio-wrapper {
        position: static !important;
    }
    .ant-radio-group {
        margin-top: 3% !important;
        display: flex;
    }
}

</style>
